/*
 *  Copyright (c) 2008 Howard Shank
 * Permission is hereby granted, free of charge, to any person obtaining a copy of 
 * this software and associated documentation files (the "Software"), to deal in 
 * the Software without restriction, including without limitation the rights to use, 
 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 
 * Software, and to permit persons to whom the Software is furnished to do so, subject 
 * to the following conditions:

 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AjaxCtrlsExtenders;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            setup();
        }
        else
        {
        }
    }

    protected void setup()
    {
        if (this.DragDropListboxExtender1.Action == DragMode.Move)
        {
            this.rbActionMove.Checked = true;
            this.rbActionCopy.Checked = false;
        }
        else
        {
            this.rbActionMove.Checked = false;
            this.rbActionCopy.Checked = true;
        }
        if (this.DragDropListboxExtender1.Unique == true)
        {
            this.rbUniqueTrue.Checked = true;
            this.rbUniqueFalse.Checked = false;
        }
        else
        {
            this.rbUniqueTrue.Checked = false;
            this.rbUniqueFalse.Checked = true;
        }

    }
    protected void grpAction_CheckedChanged(object sender, EventArgs e)
    {
        if (this.rbActionMove.Checked == true)
        {
            this.DragDropListboxExtender1.Action = DragMode.Move;
        }
        else
        {
            this.DragDropListboxExtender1.Action = DragMode.Copy;
        }
    }

    protected void grpUnique_CheckedChanged(object sender, EventArgs e)
    {
        if (this.rbUniqueTrue.Checked == true)
        {
            this.DragDropListboxExtender1.Unique = true;
        }
        else
        {
            this.DragDropListboxExtender1.Unique = false;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.DragDropListBoxBase2.Visible = this.DragDropListBoxBase2.Visible;
        this.txtOutput.Text = "Listbox 1 postback result.\n";
        foreach (ListItem item in this.DragDropListBoxBase1.Items)
        {
            this.txtOutput.Text += item.Value;
            if (item.Selected)
            {
                this.txtOutput.Text += " Selected";
            }
            this.txtOutput.Text += "\n";
        }
        this.txtOutput2.Text = "Listbox 2 postback result.\n";
        foreach (ListItem item in this.DragDropListBoxBase2.Items)
        {
            this.txtOutput2.Text += item.Value;
            if (item.Selected)
            {
                this.txtOutput2.Text += " Selected";
            }
            this.txtOutput2.Text += "\n";
        }
    }
}
